package com.zm.rpc.server.dispatcher.handler;


import com.zm.rpc.protocol.enums.RequestType;
import com.zm.rpc.server.utils.SpringBeanUtil;


/**
 * RPC请求的处理器。
 */
public interface IDispatcherHandler <T> {
    Object doExecute(T req);


    /**
     * RPC处理器的工厂方法
     * @param reqType
     * @return
     */
    static IDispatcherHandler<?> getHandler(RequestType reqType){
       
        IDispatcherHandler<?> handler = null;
         if(reqType != null){
            handler = SpringBeanUtil.getBean(reqType.getHandlerClass());
        }


        return handler;
    }
}
